<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="../plugins/elementui/index.css">
</head>
<body>

<div id="app">
    <i class="el-icon-circle-plus-outline" @click="append(null)">添加一级菜单</i>
    <el-tree
            :data="treeData"
            show-checkbox
            node-key="id"
            default-expand-all
            :expand-on-click-node="false">
      <span class="custom-tree-node" slot-scope="{ node, data }">
          <span>{{data.label}}</span>
        <i class="el-icon-circle-plus-outline" @click="append(data)"></i>
      </span>
    </el-tree>

</div>

<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script>

    var vm = new Vue({
        el:"#app",
        data:{
            treeData:[
                {id:1,label:"一级菜单1",children:[
                        {id:1-1,label:"二级菜单1",children:[]},
                        {id:1-2,label:"二级菜单2",children:[]},
                        {id:1-3,label:"二级菜单3",children:[]},
                    ]},
                {id:2,label:"一级菜单2",children:[
                        {id:2-1,label:"二级菜单1",children:[]}
                    ]},
                {id:3,label:"一级菜单3",children:[]},
            ]
        },
        methods:{
            append(data){
                console.log(data);
            }
        }
    })

</script>
</body>
</html>
